<template>
	<view class="index">
		<view class="main">
			<view class="title">商户收银辅助</view>
			<form @submit="formSubmit" class="form">
				<input class="uni-input" v-model="form.username" name="input" placeholder="收银员用户名" />
				<input class="uni-input" v-model="form.password" password name="input" placeholder="收银员密码" />
				<view class="uni-btn-v">
						<button form-type="submit" type="primary">登录</button>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				}
			}
		},
		onLoad() {

		},
		methods: {
			// /master/login/index
			formSubmit(){
				uni.showLoading({
					title:'loading...',
					mask: true
				});
				this.$http.http('master/login/index',this.form,'POST').then(res => {
					console.log('login', res);
					if(res.code === 0){
						setTimeout(()=> {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						}, 100)
					}else{
						uni.setStorageSync('token', res.data.token)
						uni.setStorageSync('city', res.data.cityid)
						uni.reLaunch({
							url: '/pages/index/shop_count'
						})
					}
					uni.hideLoading()
				})
			}
		}
	}
</script>

<style lang="scss">
	.index{
		box-sizing: border-box;
		height: 100vh;
		background-color: #f7f7f7;
		padding: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.main{
		width: 100%;
		height: 400rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.title{
		font-size: 32rpx;
		margin-bottom: 30rpx;
	}
	.form{
		width: 100%;
	}
	.uni-input{
		padding: 20rpx;
		background-color: #fff;
		margin-bottom: 20rpx;
	}
</style>
